<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>最近一分钟内广告点击趋势图</title>
    <!-- 引入 echarts.js -->
    <script src="echarts.js"></script>
    <script type="text/javascript" src="jquery-1.5.1.min.js"></script>
</head>
<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('main'));
        setInterval(function(){
            $.getJSON("adclick.json",function(data){
                var xdata = []
                var ydata = []

                $.each(data, function(i, obj){
                    xdata.push(obj.xtime)
                    ydata.push(obj.yval)
                })



                var option = {
                    xAxis: {
                        type: 'category',
                        data: xdata
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [{
                        data: ydata,
                        type: 'line'
                    }]
                };
                myChart.setOption(option);
            })
        },5000)
        
    </script>
</body>
</html>